﻿<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8" />
    <title>数据列表页面</title>
    <!-- layui.css -->
    <link th:href="@{/background/plugin/layui/css/layui.css}" href="../../static/background/plugin/layui/css/layui.css" rel="stylesheet" />
</head>
<body>
    <fieldset id="dataList" class="layui-elem-field layui-field-title sys-list-field" >
        <legend style="text-align:center;">修改账号密码</legend>
        <form class="layui-form" action="/admin/admin" method="post">
            <div class="layui-form-item">
                <label class="layui-form-label">原账号</label>
                <div class="layui-input-inline">
                    <input type="text" id="oldUserName" lay-verify="required" autocomplete="off"  class="layui-input">
                    <input type="hidden" name="_method" value="PUT">
                    <input type="hidden" name="id" th:value="${session.currentAdmin.id}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">原密码</label>
                <div class="layui-input-inline">
                    <input type="password" id="oldPassword" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">新账号</label>
                <div class="layui-input-inline">
                    <input type="text" name="userName" lay-verify="required"  autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">新密码</label>
                <div class="layui-input-inline">
                    <input type="password" name="password" lay-verify="required"  autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <button class="layui-btn" style="margin-left: 55px;" lay-submit="" lay-filter="submit" type="submit">修改</button>
                <button class="layui-btn" type="reset">重置</button>
            </div>
        </form>
    </fieldset>
    <!-- layui.js -->
    <script th:src="@{/background/plugin/layui/layui.js}" src="../../static/background/plugin/layui/layui.js"></script>
    <!-- layui规范化用法 -->
    <script th:inline="javascript" type="text/javascript">
        layui.define(['form','upload','layer'], function(exports){
            var $ = layui.jquery;
            var layer = layui.layer;
            var form = layui.form();

            var oldPassword=[[${session.currentAdmin.password}]];
            var oldUserName=[[${session.currentAdmin.userName}]];

            form.on('submit(submit)', function(data){
                if(oldUserName!=$("#oldUserName").val()||oldPassword!=$("#oldPassword").val()){
                    layer.alert('原账号名或密码错误!', {icon: 5});
                    return false;
                }
                return true;
            });
        });
    </script>
</body>
</html>